<template>
	<view>
		<!-- <cu-custom bgImage="http://yiban.likecy.cn/home1.png" >
				<block slot="content">绵师易班应用大厅</block>
		</cu-custom> -->
		<view class="bg-white">
			<view class=" padding flex flex-direction">
			<!-- 	<view class="cu-avatar round" style="background-image:url(http://img02.fs.yiban.cn/11857532/avatar/user/200);"></view> -->
				<text class="flex justify-center text-bold text-blue text-lg">绵师应用大厅</text>
				<!-- <view class="text-right"> 绵阳-多云 23-32C</view> -->
			</view>

			<swiper class="card-swiper square-dot" :indicator-dots="true" :circular="true" :autoplay="true" interval="5000"
			 duration="500" @change="cardSwiper" indicator-color="#8799a3" indicator-active-color="#0081ff">
				<swiper-item v-for="(item,index) in swiperList" :key="index" :class="cardCur==index?'cur':''">
					<view class="swiper-item">
						<image :src="item.image" mode="aspectFill"></image>
					</view>
				</swiper-item>
			</swiper>

			<view class="cu-list grid no-border col-3">
				<view class="padding flex flex-direction align-center" v-for="(item,index) in appList" :key="index" :data-type="item.type" :data-name ="item.name"
				 :data-url="item.url" @click="goToApp($event)">
					<image :src="item.image" class="myiconimg"></image>
					<text>{{item.name}}</text>
				</view>
			</view>
		</view>

		<view class="bg-white">
			<view class="cu-bar margin-top-xl ">
				<view class="action">
					<text class="cuIcon-activity text-orange"></text> 每日一句
				</view>
				<view class="action" @click="goToWhere('one/one')">
					查看更多<text class="cuIcon-right"></text>
				</view>
			</view>

			<view class="padding-lg">
				<view class="bg-olive light padding radius text-center shadow-blur">
					<view class="text-lg text-red">{{english}}</view>
					<view class="margin-top-sm text-Abc">{{chinese}}</view>
				</view>
				<!-- <view class="bg-blue light padding radius text-center shadow-blur">
					<view class="text-lg">魅红</view>
					<view class="margin-top-sm text-Abc">#f43f3b - #ec008c</view>
				</view> -->
			</view>
		</view>



		<view class="bg-white">
			<view class="cu-bar margin-top-xl ">
				<view class="action">
					<text class="cuIcon-friendfavor text-orange"></text> 网易云热评
				</view>
				<view class="action" @click="goToWhere('zhihu/zhihu')">
					查看更多<text class="cuIcon-right"></text>
				</view>
			</view>

			<view class="padding-xl">
				<view class="bg-blue light padding radius text-center shadow-blur">
					<view class="text-lg">{{music_content}}</view>
					<view class="margin-top-sm ">————《{{music_name}}》</view>
					<view class="text-right">{{music_songname}}</view>
				</view>

			</view>
		</view>


		<view class="bg-white">
			<view class="cu-bar margin-top-xl ">
				<view class="action">
					<text class="cuIcon-apps text-orange"></text> 毒汤
				</view>
				<view class="action" @click="goToWhere('zhihu/zhihu')">
					查看更多<text class="cuIcon-right"></text>
				</view>
			</view>
			<view class="padding-xl">
				<view class="bg-pink light padding radius text-center shadow-blur">
					<view class="text-lg">{{dutang_content}}</view>
				</view>

			</view>
		</view>










	</view>
</template>

<script>
	var _self;

	// import request from '../../components/pocky-request/index.js';
	export default {
		data() {
			return {
				cardCur: 0,
				english: '',
				chinese: '',
				dutang_content: '',
				music_content: '',
				music_songname: '',
				music_name: '',
				swiperList: [],
				dotStyle: false,
				towerStart: 0,
				direction: '',
				appList: []
			}
		},

		onLoad(option) {
			console.log(option.token);
			if(option.token){
			uni.setStorageSync('token',option.token);
			uni.setStorageSync('token',option.token);
			uni.setStorageSync('token',option.token);
			uni.setStorageSync('token',option.token);
			}else{
				window.open("http://yiban.likecy.cn/yiban","_blank");
			}
			_self = this;			
			this.getmusistop();
			this.getDutang();
			this.getWords();
			this.getAppList();
			this.getswiperList();
		},

		methods: {
			
			
			getswiperList(){
				this.$http.get('api/home/getSwiperList')
					.then(res => {
						// console.log(res);
					_self.swiperList = res.data.data;
					})
					.catch(err => {});
			},

			getAppList() {
				
				
				this.$http.get('api/home/getapplist')
					.then(res => {
						// console.log(res);
					_self.appList = res.data.data;
					})
					.catch(err => {});
			},


			getmusistop() {
				
				
					this.$http.get('api/index/getMusicTop')
					.then(res => {
						// console.log(res);
					_self.music_content = res.data.content;
				_self.music_songname = res.data.songname;
				_self.music_name = res.data.name;
					})
					.catch(err => {});
			},
			getDutang() {
					this.$http.get('api/index/getDuTang')
					.then(res => {
						// console.log(res);
				_self.dutang_content = res.data.data[0].content;
					})
					.catch(err => {});
				
			},
			getWords() {
				
					this.$http.get('api/index/getword')
					.then(res => {
						// console.log(res);
				_self.english = res.data[0].english;
				_self.chinese = res.data[0].chinese;
					})
					.catch(err => {});
				
			},

			goToApp(e) {
				var app =e.currentTarget.dataset;
				
				if(app.type ==1){
					uni.navigateTo({
						url:app.url
					});
				}else{
					uni.navigateTo({
						url:'outside/outside?name='+app.name+"&url="+app.url
					});
					
				}
			},

			goToWhere(e) {
				uni.navigateTo({
				 	url:e
				 });
			},
			DotStyle(e) {
				this.dotStyle = e.detail.value
			},
			// cardSwiper
			cardSwiper(e) {
				this.cardCur = e.detail.current
			},

		}
	}
</script>

<style>
	.tower-swiper .tower-item {
		transform: scale(calc(0.5 + var(--index) / 10));
		margin-left: calc(var(--left) * 100upx - 150upx);
		z-index: var(--index);
	}

	.myiconimg {
		width: 88upx;
		height: 88upx;
		text-align: center;
	}
</style>
